import { request } from '@umijs/max';
import qs from 'qs';

export async function list(body: API.LoginParams, options?: { [key: string]: any }) {
  return request('http://localhost:9902/api/admin/textApp/list', {
    method: 'POST',
    data: qs.stringify(body),
    ...(options || {}),
  }).then((res) => ({
    success: true,
    data: res.data.content,
    total: res.data.total,
  }));
}
export async function save(body: Record<string, any>, options?: { [key: string]: any }) {
  return request(`http://localhost:9902/api/admin/textApp/${body.id?'update':'save'}`, {
    method: 'POST',
    data: qs.stringify(body),
    ...(options || {}),
  });
}
export async function remove(body: Record<string, any>, options?: { [key: string]: any }) {
  return request('http://localhost:9902/api/admin/textApp/delete', {
    method: 'POST',
    data: qs.stringify(body),
    ...(options || {}),
  });
}
export async function detail(body: Record<string, any>, options?: { [key: string]: any }) {
  return request('http://localhost:9902/api/admin/textApp/detail', {
    method: 'POST',
    data: qs.stringify(body),
    ...(options || {}),
  });
}
export async function category(options?: { [key: string]: any }) {
  return request('http://localhost:9902/api/admin/textApp/category', {
    method: 'POST',
    ...(options || {}),
  });
}
